export interface Point {
    x: number;
    y: number;
}

export type DrawMode = 'fill' | 'stroke';
export enum DrawModeEnum {
    Fill = 'fill',
    Stroke = 'stroke'
}

export type DrawType = 'line' | 'image' | 'text' | 'rect' | 'circle' | 'ellipse' | 'roundRect';

export enum CursorEnum {
    Auto = 'auto',
    Crosshair = 'crosshair',
    Move = 'move',
    Text = 'text',
    LeftDown = 'ne-resize',
    LeftUp = 'nw-resize',
    UpDown = 'ns-resize',
    LeftRight = 'ew-resize',
    pointer = 'pointer',
    ZoomIn = 'zoom-in',
    ZoomOut = 'zoom-out',
    grab = 'grab',
    grabbing = 'grabbing',
    NotAllowed = 'not-allowed'
}

export interface DrawOption {
    type: DrawType;
    x: number;
    y: number;
    lineCap?: CanvasLineCap;
    lineDashOffset?: number;
    lineJoin?: CanvasLineJoin;
    lineWidth?: number;
    miterLimit?: number;
    points?: Point[];
}

export interface IShape {
    points?: Point[];
    update: (...params: any) => any;
    render: (...params: any) => any;
    checkClick: (...params: any) => any;
    drawBorder: (ctx: CanvasRenderingContext2D) => any;
    drawControls: (ctx: CanvasRenderingContext2D) => any;
    getControlRect: (...params: any) => any;
    getPointIsInsideArea: (...params: any) => any;
    getIsInControlArea: (point: Point) => boolean;
    getOnControlType: (point: Point) => { cursor: CursorEnum, controlType: ControlTypeEnum | boolean };
    handleAction: (...params: any) => any;

}

export interface IControlRect {
    x: number;
    y: number;
    width: number;
    height: number;
}

export enum ControlTypeEnum {
    TL = 'tl', // top left
    TC = 'tc', // top center
    TR = 'tr', // top right
    ML = 'ml', // middle left
    MR = 'mr', // middle right
    BL = 'bl', // bottom left
    BC = 'bc', // bottom center
    BR = 'br', // bottom right
    ROTATE = 'rotate' // top rotate
}

export interface IControlPoint {
    [ControlTypeEnum.TL]: Point;
    [ControlTypeEnum.TC]: Point;
    [ControlTypeEnum.TR]: Point;
    [ControlTypeEnum.ML]: Point;
    [ControlTypeEnum.MR]: Point;
    [ControlTypeEnum.BL]: Point;
    [ControlTypeEnum.BC]: Point;
    [ControlTypeEnum.BR]: Point;
    [ControlTypeEnum.ROTATE]: Point;
}
